<?php


namespace Part23_CommandMode\Code3;

/**
 * 服务员
 */
class Waiter
{
    /**
     * @var Command[] 增加存放具体命令的容器
     */
    private $orders;

    /**
     * @param $command Command
     */
    public function setOrder($command)
    {
        $className = get_class($command);
        // 对没货的烧烤进行回绝
        if ($className == BakeChickenWingCommand::class) {
            echo "服务员：鸡翅没了，点别的吧\n";
        } else {
            // 记录用户点的烧烤
            $this->orders[] = $command;
            $date = date('Y-m-d H:i:s');
            echo "增加订单：{$className}，时间：{$date}\n";
        }
    }

    public function cancelOrder()
    {
        // 取消订单，从数组中剔除，并记录日志
    }

    public function notify()
    {
        foreach ($this->orders as $order) {
            $order->executeCommand();
        }
    }
}